﻿using System;
using System.Collections.Generic;
using System.Text;
using DAL.DateSet.GoodsAppendTableAdapters;
using DAL;
using DAL.DateSet;
namespace BLL.Wrapper
{
    public class GoodsAppendWrapper : GoodsAppendTableAdapter
    {
        public GoodsAppend.GoodsAppendDataTable getall()
        {
            return GetData();
        }

        public void addARecord(GoodsAppend.GoodsAppendRow row)
        {
            Insert(row.goodsID, row.appendName, row.appendValue, row.appendType, row.isNull, row.appendCreator, row.appendCreateDate);
        }

        public void deleteByID(int id)
        {
            string sql = "delete from GoodsAppend where appendID = " + id.ToString();
            HouseDiyHelper helper = HouseDiyHelper.GetInstance();
            helper.initOle();
            helper.delete(sql);
        }

        public void deleteByGoodsID(int id)
        {
            string sql = "delete from GoodsAppend where goodsID = " + id.ToString();
            HouseDiyHelper helper = HouseDiyHelper.GetInstance();
            helper.initOle();
            helper.delete(sql);
        }

        public void updateARecord(GoodsAppend.GoodsAppendRow row)
        {
            GoodsAppend.GoodsAppendDataTable table = GetData();
            for (int i = 0; i < table.Rows.Count; i++)
            {
                if (Convert.ToInt32(table.Rows[i]["appendID"]) == row.appendID)
                {
                    table.Rows[i]["goodsID"] = row.goodsID;
                    table.Rows[i]["appendName"] = row.appendName;
                    table.Rows[i]["appendValue"] = row.appendValue;
                    table.Rows[i]["appendType"] = row.appendType;
                    table.Rows[i]["isNull"] = row.isNull;
                    table.Rows[i]["appendCreator"] = row.appendCreator;
                    table.Rows[i]["appendCreateDate"] = row.appendCreateDate;
                    break;
                }
            }
            Update(table);
        }
    }
}
